import {createRouter, createWebHistory} from 'vue-router';

import Layout from '@/layout/index.vue';

const routes = [
    {
        path: '/index',
        meta: {
            title: '平台首页',
            icon: 'HomeOutlined',
            key: 'index'
        },
        component: Layout,
        children: [
            {
                path: '',
                component: () => import('@/views/index.vue')
            }
        ]
    },
    {
        path: '/record',
        component: Layout,
        children: [
            {
                path: 'personage',
                meta: {
                    title: '人物大全',
                    icon: 'TeamOutlined',
                    key: 'record:personage:list'
                },
                component: () => import('@/views/record/personage/index.vue')
            },
            {
                path: 'personage/detail',
                meta: {
                    title: '人物详情',
                    icon: 'AuditOutlined',
                    key: 'record:personage:detail'
                },
                component: () => import('@/views/record/personage/detail.vue')
            }
        ]
    },
    // 首页跳转index
    {
        path: '/:lang(.*)',
        redirect: '/index'
    }
];

export default createRouter({
    history: createWebHistory(),
    fallback: false,
    routes,
    scrollBehavior: to => {
        if (to.hash) {
            return {el: to.hash, top: 80, behavior: 'auto'};
        }
    }
});